//
//  CouponsTableCell.m
//  DingDongXiChe
//
//  Created by wtjr on 2018/1/11.
//  Copyright © 2018年 xieyingze. All rights reserved.
//

#import "CouponsTableCell.h"

@interface CouponsTableCell()

@property (nonatomic, strong) UIView *mainView;

@property (nonatomic, strong) BaseLabel *couponseTitle;

@property (nonatomic, strong) BaseLabel *couponsePrice;

@property (nonatomic, strong) BaseLabel *couponseDescription;

@property (nonatomic, strong) BaseLabel *couponseTime;

@end

@implementation CouponsTableCell

+ (instancetype)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath {
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    static NSString *cellId = @"CouponsTableCell";
    CouponsTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (cell == nil) {
        cell = [[CouponsTableCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
    }
    return cell;
}

#pragma mark - init

- (void)initSubView {
    [self addSubview:self.mainView];
}

- (void)autoLayoutSubviews {
    [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@0);
    }];
}

#pragma mark - Method


#pragma mark - Interface


#pragma mark - Setter


#pragma mark - Getter

- (UIView *)mainView {
    if (!_mainView) {
        _mainView = [UIView new];
        _mainView.backgroundColor = kCOLOR_tableView;

        UIView *part1View = [UIView new];
        part1View.backgroundColor = kCOLOR_white;
        [part1View setViewShadow:kCOLOR_RGBValue(0xeaeaea) offset:CGSizeMake(0, -kUI_ShawRadius) radius:kUI_ShawRadius];
        [_mainView addSubview:part1View];
        [part1View mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@20);
            make.right.equalTo(@-20);
            make.top.equalTo(@10);
            make.height.equalTo(@60);
        }];
        
        BaseLabel *couponseTitle = [BaseLabel new];
        [couponseTitle setLabelStyle:@"环保洗车优惠券" textColor:KCOLOR_mainColor textFont:kFONT_mainBoldFont(16) texrAlignment:NSTextAlignmentLeft];
        self.couponseTitle = couponseTitle;
        [part1View addSubview:couponseTitle];
        [couponseTitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@20);
            make.centerY.equalTo(@0);
            make.height.equalTo(@20);
        }];
        
        BaseLabel *couponsePrice = [BaseLabel new];
        [couponsePrice setLabelStyle:@"¥24" textColor:kCOLOR_mainRed textFont:kFONT_mainBoldFont(18) texrAlignment:NSTextAlignmentRight];
        self.couponsePrice = couponsePrice;
        [part1View addSubview:couponsePrice];
        [couponsePrice mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(@-20);
            make.centerY.equalTo(@0);
            make.height.equalTo(@20);
        }];
        
        CustomConcaveView *concaveView = [[CustomConcaveView new] initWith:CGSizeMake(kUI_WIDTH - 40, 20)];
        [_mainView addSubview:concaveView];
        [concaveView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(part1View);
            make.top.equalTo(part1View.mas_bottom);
            make.height.equalTo(@20);
        }];
        
        UIView *part2View = [UIView new];
        part2View.backgroundColor = kCOLOR_white;
        [part2View setViewShadow:kCOLOR_RGBValue(0xeaeaea) offset:CGSizeMake(0, kUI_ShawRadius) radius:kUI_ShawRadius];
        [_mainView addSubview:part2View];
        [part2View mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(part1View);
            make.top.equalTo(concaveView.mas_bottom);
            make.height.equalTo(@20);
        }];
        
        BaseLabel *couponseDescription = [BaseLabel new];
        [couponseDescription setLabelStyle:@"满68元可用" textColor:KCOLOR_font_light textFont:kFONT_mainFont(10) texrAlignment:NSTextAlignmentLeft];
        self.couponseDescription = couponseDescription;
        [part2View addSubview:couponseDescription];
        [couponseDescription mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@20);
            make.centerY.equalTo(@0).offset(-2);
            make.height.equalTo(@10);
        }];
        
        BaseLabel *couponseTime = [BaseLabel new];
        [couponseTime setLabelStyle:@"有效期:2018-2-12" textColor:KCOLOR_font_light textFont:kFONT_mainFont(10) texrAlignment:NSTextAlignmentRight];
        self.couponseTime = couponseTime;
        [part2View addSubview:couponseTime];
        [couponseTime mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(@-20);
            make.centerY.equalTo(@0).offset(-2);
            make.height.equalTo(@10);
        }];
    }
    return _mainView;
}


@end
